package com.ruoyi.project.user.kkidmapper.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.user.kkidmapper.domain.KkidMapper;
import com.ruoyi.project.user.kkidmapper.mapper.KkidMapperMapper;
import com.ruoyi.project.user.kkidmapper.service.IKkidMapperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * kkid映射Service业务层处理
 *
 * @author shixiangwen
 * @date 2022-10-11
 */
@Service
@DataSource(DataSourceType.ACCOUNT)
public class KkidMapperServiceImpl implements IKkidMapperService {
    @Autowired
    private KkidMapperMapper kkidMapperMapper;

    /**
     * 查询kkid映射
     *
     * @param id kkid映射ID
     * @return kkid映射
     */
    @Override
    public KkidMapper selectKkidMapperById(Long id) {
        return kkidMapperMapper.selectKkidMapperById(id);
    }

    /**
     * 查询kkid映射列表
     *
     * @param kkidMapper kkid映射
     * @return kkid映射
     */
    @Override
    public KkidMapper queryKkidMapper(KkidMapper kkidMapper) {
        List<KkidMapper> kkidMappers = kkidMapperMapper.selectKkidMapperList(kkidMapper);
        if (!kkidMappers.isEmpty()) {
            return kkidMappers.get(0);
        }
        return null;
    }

    /**
     * 新增kkid映射
     *
     * @param kkidMapper kkid映射
     * @return 结果
     */
    @Override
    public int insertKkidMapper(KkidMapper kkidMapper) {
        kkidMapper.setCreateTime(DateUtils.getNowDate());
        return kkidMapperMapper.insertKkidMapper(kkidMapper);
    }

    /**
     * 修改kkid映射
     *
     * @param kkidMapper kkid映射
     * @return 结果
     */
    @Override
    public int updateKkidMapper(KkidMapper kkidMapper) {
        kkidMapper.setUpdateTime(DateUtils.getNowDate());
        return kkidMapperMapper.updateKkidMapper(kkidMapper);
    }

    /**
     * 删除kkid映射对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteKkidMapperByIds(String ids) {
        return kkidMapperMapper.deleteKkidMapperByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除kkid映射信息
     *
     * @param id kkid映射ID
     * @return 结果
     */
    @Override
    public int deleteKkidMapperById(Long id) {
        return kkidMapperMapper.deleteKkidMapperById(id);
    }
}
